package cn.ydxiaoshuai.drools;

import cn.ydxiaoshuai.drools.utils.SendMailUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author 小帅丶
 * @className YDDroolApplicationTest
 * @Description TEST
 * @Date 2021-06-09-14:29
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class YDDroolApplicationTest {
    @Autowired
    SendMailUtil sendMailUtil;

    @Test
    public void sendHtmlMessage() throws Exception{
        String nickName = "小帅";
        String mails[] = {"youngxiaoshuai@163.com"};
        String content = "我们这个年纪，没有相爱这回事，只是互相顺眼而已。要到后来，又老又无力了，才可能相爱。" +
                "我们这个年纪，没有相爱这回事，只是互相顺眼而已。要到后来，又老又无力了，才可能相爱。" +
                "我们这个年纪，没有相爱这回事，只是互相顺眼而已。要到后来，又老又无力了，才可能相爱。";
        sendMailUtil.sendHtmlMail("邮件测试",nickName, content,mails);
    }
//    @Test
//    public void getIPISPInfo(){
//        long startTime = System.currentTimeMillis();
//        String path = "http://ipapi.api.bdymkt.com/ip2location/retrieve";
//        ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
//        request.setCredentials("3073a33a513e468eb7aab3529dd9b80e", "f6f11d4a2492460d8f3add78ce52f888");
//        // 设置header参数
//        request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8");
//        // 设置jsonBody参数
//        String jsonBody = "{\"ip\": \"183.253.162.104\"}";
//        request.setJsonBody(jsonBody);
//        ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
//
//        try {
//            ApiExplorerResponse response = client.sendRequest(request);
//            // 返回结果格式为Json字符串
//            System.out.println(response.getResult());
//            long endTime = System.currentTimeMillis();
//            System.out.println(endTime-startTime);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
}
